package com.fivetalks.client;

import java.io.IOException;
import java.net.Socket;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class SettingDialogActivity extends Activity 
implements OnClickListener
{
	private EditText etnickname = null;
	private TextView tvnickname = null;
	
	Button btSubmit;
	Button btCancel;
	Thread m_thread;
	Socket m_socket;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting_dialog);
		
		btSubmit=(Button)findViewById(R.id.btNicknameSubmit);
		btSubmit.setOnClickListener(this);
		
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btNicknameSubmit:
			
			LayoutInflater layout = getLayoutInflater();
			final View v2 = layout.inflate(R.layout.activity_setting, null);
			
			etnickname = (EditText) findViewById(R.id.etNickname);
			
			//tvnickname = (TextView) v2.findViewById(R.id.tvNickname_activity_setting);
			
			//tvnickname.setText(etnickname.getText().toString());
			//start();//닉네임 변경 완료 후 복귀
			Intent intent=new Intent(this,SettingActivity.class);
			
			intent.putExtra("nickname", etnickname.getText().toString());
			
			this.setResult(RESULT_OK, intent); // 성공했다는 결과값을 보내면서 데이터 꾸러미를 지고 있는 intent를 함께 전달한다.
			this.finish();
//			
//			startActivity(intent);
//			finish();
		}
	}
/*
	public void start() {
		
		//android:id="@+id/tvNickname_activity_setting"
		//R.id.tvNickname_activity_setting
		
		
//		R.string.nickname_update_activity_setting = "건방져";
//		m_thread = new Thread(this);
//		m_thread.start();
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		
	}
*/
///////텍스트뷰 수정 처리!!!!//////
/*	public void run() {
		
		SocketClient sc = SocketClient.getInstance();
		
		// room create.
		EditText etnickname=(EditText)findViewById(R.id.etNickname);
		
		try {
			
			//sc.getDos().writeUTF("createRoom");
			sc.getDos().writeUTF("editNickname");   //editNickname 처리부
			sc.getDos().writeUTF(sc.getUserId()+"");
			R.string.nickname_update_activity_setting = 
			
//			sc.getDos().writeUTF(sc.getUserId() +"");
//			sc.getDos().writeUTF(etRoomTitle.getText().toString());
		sc.getDos().flush();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}*/
}
